package com.wenwan.manage.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wenwan.manage.service.GiveGetCommentClientService;

import javax.annotation.Resource;

/**
 * 供求文章子评论
 * 
 * @author Admin
 *
 */
@Controller
@RequestMapping(value = "/give/get/comment/client")
public class GiveGetCommentClientController {

	@Autowired
	private GiveGetCommentClientService giveGetCommentClientService;

	/**
	 * 供求文章子评论
	 * 
	 * @param content
	 *            评论内容
	 * @param fromUserId
	 *            评论者
	 * @param toUserId
	 *            被评论者
	 * @param giveGetCommentId
	 *            供求文章评论ID
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/create", method = { RequestMethod.POST })
	public Map<String, Object> create(@RequestParam(required = true) String content,
			@RequestParam(required = true) String fromUserId, @RequestParam(required = true) String toUserId,
			@RequestParam(required = true) String giveGetCommentId) {
		return giveGetCommentClientService.create(content, fromUserId, toUserId, giveGetCommentId);
	}

	/**
	 * 删除供求文章子评论
	 * 
	 * @param id
	 *            供求文章子评论ID
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/delete/by/id", method = { RequestMethod.POST })
	public Map<String, Object> deleteById(@RequestParam(required = true) String id) {
		return giveGetCommentClientService.deleteById(id);
	}

	/**
	 * 更新供求文章子评论
	 * 
	 * @param id
	 *            供求文章子评论ID
	 * @param content
	 *            评论内容
	 * @param fromUserId
	 *            评论者
	 * @param toUserId
	 *            被评论者
	 * @param giveGetCommentId
	 *            评论ID
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/update", method = { RequestMethod.POST })
	public Map<String, Object> update(@RequestParam(required = true) String id,
			@RequestParam(required = false) String content, @RequestParam(required = false) String fromUserId,
			@RequestParam(required = false) String toUserId, @RequestParam(required = false) String giveGetCommentId) {
		return giveGetCommentClientService.update(id, content, fromUserId, toUserId, giveGetCommentId);
	}

}
